﻿from pydbg import *
from pydbg.defines import *

import utils

#非法内存操作处理器
def check_accessv(dbg):
	
	#忽略
	if dbg.dbg.u.Exception.dwFirstChance:
		return DBG_EXCEPTION_NOT_HANDLED
		
	crash_bin = utils.crash_binning.crash_binning()
	crash_bin.record_crash(dbg)
	print crash_bin.crash_synopsis()
	
	dbg.terminate_process()
	
	return DBG_EXCEPTION_NOT_HANDLED
	
pid = raw_input("Enter the Process ID: ")

dbg = pydbg()
dbg.attach(int(pid))
dbg.set_callback(EXCEPTION_ACCESS_VIOLATION, check_accessv)
dbg.run()
	